package com.atguigu.interactive.v1;

class AirCondition {
    private int number = 0;
    public synchronized void increment() throws InterruptedException {
        while(number != 0){
            wait();
        }
        System.out.println(Thread.currentThread().getName()+"\t"+(++number));
        this.notifyAll();
    }
    public synchronized  void decrement() throws InterruptedException {
        while(number == 0){
            wait();
        }
        System.out.println(Thread.currentThread().getName()+"\t"+(--number));
        this.notifyAll();
    }
}
